//
//  HWPhoneNumberLoginController.m
//  HWanGame
//
//  Created by 陈道斌 on 2020/10/19.
//  Copyright © 2020 Chendaobin. All rights reserved.
//

#import "HWPhoneNumberLoginController.h"
#import "HWLoginController.h"
#import "HWAccountRegisteredViewController.h"
#import "Countdown.h"

#import "HWWebViewGameViewController.h"
#import "HWLoginController.h"



@interface HWPhoneNumberLoginController (){
    
     NSString *member_id; //推广id
    
}
@property(strong,nonatomic) UIView *registeredView;
@property(strong,nonatomic) UITextField *accounttextField;
@property(strong,nonatomic) UITextField *miaTexfeild;
@property(strong,nonatomic) UITextField *zaicemimaTeFeild;
@property(strong,nonatomic) UITextField *inviteTextField;
@property(strong,nonatomic) UIImageView *icoImageView;
@property(strong,nonatomic) NSString *agreeDealStr; // 0 代表不同意 1 。代表已同意了协议
@property(strong,nonatomic) UITextField *yaoqingTextField; // 邀请码
@property(strong,nonatomic) UIImageView *zhanghaoiamgeView; // 账号注册
@property(strong,nonatomic) UIView *logiviewOrweixingView;
@property(strong,nonatomic) UIImageView *headIcoImageView;
@property(strong,nonatomic) NSString *sessionid;

@property(strong,nonatomic) UIButton *loginBut;
@property(strong,nonatomic) UILabel *xieyilingsiLabel;

@property(strong,nonatomic) NSString *panduanStr; // 1 代表已经注册 0 代表没有
@property(strong,nonatomic) HWLoginController *logindenglu;
 




@end

@implementation HWPhoneNumberLoginController

- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
    
    [self.navigationController setNavigationBarHidden:YES ];
}

- (void)viewWillDisappear:(BOOL)animated {
    [super viewWillDisappear:animated];
      [self.navigationController setNavigationBarHidden:NO];
   // [self.navigationController setNavigationBarHidden:NO animated:animated];
}





- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    self.panduanStr = @"1";
    
    [self setupUI];
    [self navigaView];
    [self addlogingkongjiangView];
    [self tianjiankongzhi];
    
  
    
    
    
    
}







- (void)tianjiankongzhi {
    
    self.logindenglu = [[HWLoginController alloc]init];
    self.logindenglu.shifouJiaruStr = @"1";
    [self addChildViewController:self.logindenglu];
    
     [self.view addSubview:self.logindenglu.view];
    
    self.logindenglu.view.hidden = YES;
    
    
}


- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{
    
    [self.view endEditing:YES];
    
    
}




- (void)setupUI {
    
    self.view.backgroundColor = [UIColor whiteColor];
    UIImageView *beijiimageView = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, kScreenW, 249*CFLScaleValue+StatusBarHeight)];
    beijiimageView.image = [UIImage imageNamed:@"login_sign_bg"];
    beijiimageView.userInteractionEnabled = YES;
    beijiimageView.hidden = YES;
    [self.view addSubview:beijiimageView];
    [self addRegisteredView];

    
    
}







//添加一些登录控件 微信 QQ 手机号登录  用户注册
- (void)addlogingkongjiangView {
        
    
    
    
    
     UILabel *nameLabel = [[UILabel alloc]initWithFrame:CGRectMake(40,kScreenH -48-CF_TabbarSafeBottomMargin-10-17-20, kScreenW-80, 17)];
                //     nameLabel.text = fanlilistArr[i];
         //  nameLabel.backgroundColor =  RGB(248, 119, 6);
    nameLabel.backgroundColor = [UIColor clearColor];
    nameLabel.textAlignment = NSTextAlignmentCenter;
    nameLabel.font = [UIFont systemFontOfSize:14];
    nameLabel.textColor = RGB(170 , 170, 170);
      //     nameLabel.layer.cornerRadius = 8;
      //     nameLabel.layer.masksToBounds = YES;
     nameLabel.text = @"如没有账号，请点击用户注册按钮注册平台账号";
     nameLabel.text  = [HWjianzhiduiObject keylocalization:@"如没有账号，请点击用户注册按钮注册平台账号"];

    
     [self.view addSubview:nameLabel];
    
    
    
    
      self.logiviewOrweixingView = [[UIView alloc]initWithFrame:CGRectMake(0, kScreenH -48-CF_TabbarSafeBottomMargin-10, kScreenW, 48)];
      self.logiviewOrweixingView.backgroundColor = [UIColor clearColor];
      [self.view addSubview:self.logiviewOrweixingView];
    
    
    
    
    
//     NSArray *arr1 = @[@"shoujidengluhao",@"weixindengluico",@"QQdengluico",@"youkedengluzhuce"];
//     NSArray *arr2 = @[@"手机登录",@"微信登录",@"QQ 登录",@"用户注册"];
    
    
    // zhanghaodenLu
//    NSArray *arr1 = @[@"shoujidengluhao",@"zhanghaodenLu",@"weixindengluico",@"QQdengluico"];
//    NSArray *arr2 = @[@"手机登录",@"账号登录",@"微信登录",@"QQ 登录"];
//
    
    
//     NSArray *arr1 = @[@"zhanghaodenLu",@"weixindengluico",@"QQdengluico",@"youkedengluzhuce"];
//     NSArray *arr2 = @[@"帐号登录",@"微信登录",@"QQ 登录",@"用户注册"];
//

    NSArray *arr1 = nil;
    NSArray *arr2 = nil;
    
    if ([[HWLocallyStoredData getLogQQAndWeichat] isEqualToString:@"1"]) {
        
        
        arr1 = @[@"zhanghaodenLu",@"youkedengluzhuce"];
       //  arr2 = @[@"账号登录",@"用户注册"];
        arr2 = @[[HWjianzhiduiObject keylocalization:@"账号登录"],[HWjianzhiduiObject keylocalization:@"用户注册"]];
         
    } else {
        
        arr1 = @[@"zhanghaodenLu",@"weixindengluico",@"QQdengluico",@"youkedengluzhuce"];
        // arr2 = @[@"账号登录",@"微信登录",@"QQ 登录",@"用户注册"];
        arr2 = @[[HWjianzhiduiObject keylocalization:@"账号登录"],@"微信登录",@"QQ 登录",[HWjianzhiduiObject keylocalization:@"用户注册"]];
        
    }
    
    
    

    
     CGFloat hengjianju = (kScreenW  - arr1.count*54)/(arr1.count+1);
    //  CGFloat  shujianju = (166-100)/3;
     
     for (int i = 0 ; i < arr1.count; i++) {
      //    int row = i/4;
         int line = i% arr1.count;


         UIView *beijingview = [[UIView alloc]initWithFrame:CGRectMake(line*54+hengjianju*i+hengjianju, 0, 50+4, 48)];
        beijingview.backgroundColor = [UIColor clearColor];
         [self.logiviewOrweixingView addSubview:beijingview];
         
         beijingview.tag = i;
         UITapGestureRecognizer *beijingGesture = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(zhanghaobeijingTap:)];
         [beijingview addGestureRecognizer:beijingGesture];
         
         
         
         
         UIImageView *imageView = [[UIImageView alloc]initWithFrame:CGRectMake((54-24)/2, 0, 24, 24)];
        // imageView.image = [UIImage imageNamed:self.icoArr[i]];
      //   imageView.userInteractionEnabled = YES;
         imageView.image =  [UIImage imageNamed:arr1[i]];
         [beijingview addSubview:imageView];
         imageView.tag = i;
        //  [self.imageViewMuArr addObject:imageView];
         
         
//         UITapGestureRecognizer *tap  = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(iamgetap:)];
//         [imageView addGestureRecognizer:tap];
         
         
         
         UILabel *shulianlabel = [[UILabel alloc]initWithFrame:CGRectMake(0, 30, 54, 20)];
         shulianlabel.textColor =RGB(68, 68, 68);
       //  shulianlabel.text = self.listArr[i];
              //  shulianlabel.backgroundColor = [UIColor orangeColor];
         shulianlabel.font = [UIFont systemFontOfSize:12];
         shulianlabel.textAlignment = NSTextAlignmentCenter;
         shulianlabel.text = arr2[i];

         [beijingview addSubview:shulianlabel];
      //    [self.labeMuArr addObject:shulianlabel];
         
  
         
     
     }
    
    
    
    
    
    
    
}





- (void)addRegisteredView {
    
    
    
//    self.zhanghaoiamgeView  = [[UIImageView alloc]initWithFrame:CGRectMake((kScreenW-102)/2, 60+StatusBarHeight, 102, 23)];
//    self.zhanghaoiamgeView.image = [UIImage imageNamed:@"zhanghaozhucejiemian"];
//    [self.view addSubview:self.zhanghaoiamgeView];
    
    
    
     NSDictionary *dic =  [[NSBundle mainBundle] infoDictionary];
     NSString *icostr =     dic[@"CFBundleIcons"][@"CFBundlePrimaryIcon"][@"CFBundleIconName"];
    //UIImage *appIcon = [UIImage imageNamed: [[[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleIcons"] objectAtIndex:0]];
     UIImage  *appIcon = [UIImage imageNamed:icostr];
     appIcon = [UIImage imageNamed:@"AppIcon"];
     
    self.icoImageView = [[UIImageView alloc]initWithFrame:CGRectMake((kScreenW-50)/2, StatusBarHeight+44, 50, 50)];
    //   self.icoImageView.image = [UIImage imageNamed:@"acat"];
      self.icoImageView.layer.cornerRadius = 10;
      self.icoImageView.layer.masksToBounds = YES;
      self.icoImageView.image = appIcon;
    //   self.icoImageView.layer.borderWidth = 5;
    //  self.icoImageView.layer.borderColor  =  RGB(255, 255, 255).CGColor;
     //  [self.loginView addSubview: self.icoImageView];
    [self.view addSubview:self.icoImageView];
    
      
    
    
    // 忘记密码
    
    
    
    
    
    self.registeredView = [[UIView alloc]initWithFrame:CGRectMake(50, 60+StatusBarHeight+40+30, kScreenW-100, 65*4+12*3)];
    self.registeredView.backgroundColor = [UIColor redColor];
    self.registeredView.backgroundColor = [UIColor whiteColor];
    self.registeredView.clipsToBounds = YES;
    self.registeredView.frame = CGRectMake(50, 60+StatusBarHeight+40+30, kScreenW-100, 65*2+12*1);
    
    
    
    
//    self.registeredView.backgroundColor = [UIColor whiteColor];
//    self.registeredView.layer.shadowColor = [UIColor colorWithRed:26/255.0 green:113/255.0 blue:255/255.0 alpha:0.35].CGColor;
//    self.registeredView.layer.shadowOffset = CGSizeMake(0,0);
//    self.registeredView.layer.shadowOpacity = 1;
//    self.registeredView.layer.shadowRadius = 10;
//    self.registeredView.layer.cornerRadius = 6;
//    self.registeredView.layer.masksToBounds = YES;
//    self.registeredView.clipsToBounds = NO;
    [self.view addSubview:self.registeredView];
    
    
    
    
    
    UILabel *zhanghanameLabel1 = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, 100, 17)];
          //     nameLabel.text = fanlilistArr[i];
    zhanghanameLabel1.textAlignment = NSTextAlignmentLeft;
    zhanghanameLabel1.font = [UIFont systemFontOfSize:13];
    zhanghanameLabel1.textColor = RGB(68, 68, 68);
    zhanghanameLabel1.text = @"手机号码";
    zhanghanameLabel1.text = [HWjianzhiduiObject keylocalization:@"手机号码"];
    
    [self.registeredView addSubview:zhanghanameLabel1];
    
    
    
    UITextField *textfeild = [[UITextField alloc]initWithFrame:CGRectMake(0, 21, self.registeredView.width , 44)];
    textfeild.placeholder = @"请输入";
    textfeild.placeholder = [HWjianzhiduiObject keylocalization:@"请输入"];
    
    textfeild.keyboardType = UIKeyboardTypeASCIICapable;
    textfeild.textColor = RGB(68, 68, 68);
    textfeild.font = [UIFont systemFontOfSize:14];
    textfeild.backgroundColor = RGB(245, 245, 252);
 //    textfeild.borderStyle =UITextBorderStyleNone;
//    textfeild.layer.borderWidth = 1;
//    textfeild.layer.borderColor = RGB(230, 239, 233).CGColor;
    textfeild.layer.cornerRadius = 22;
    textfeild.layer.masksToBounds = YES;
    UIView *youbinview = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 12, 35)];
    textfeild.leftView = youbinview;
    
    
//    UIImageView *imgeView = [[UIImageView alloc]initWithFrame:CGRectMake(11, 9, 16, 16)];
//    imgeView.image = [UIImage imageNamed:@"sign_phone"];
//    [youbinview addSubview:imgeView];
//
    
    self.accounttextField = textfeild;
    textfeild.leftViewMode = UITextFieldViewModeAlways;
    [self.registeredView addSubview:textfeild];
    
    textfeild.clearsOnBeginEditing = NO;
    textfeild.clearButtonMode = UITextFieldViewModeWhileEditing;

    UIButton *userNameClearButton = [textfeild valueForKey:@"_clearButton"];
    [userNameClearButton setImage:[UIImage imageNamed:@"shanchuanniu"] forState:UIControlStateNormal];
    
    
    
    
    
     UILabel *zhanghanameLabel2 = [[UILabel alloc]initWithFrame:CGRectMake(0,self.accounttextField.bottom+12 , 100, 17)];
           //     nameLabel.text = fanlilistArr[i];
       zhanghanameLabel2.textAlignment = NSTextAlignmentLeft;
       zhanghanameLabel2.font = [UIFont systemFontOfSize:13];
       zhanghanameLabel2.textColor = RGB(68, 68, 68);
        zhanghanameLabel2.text = @"验证码";
    zhanghanameLabel2.text =  [HWjianzhiduiObject keylocalization: @"验证码"];
    
      [self.registeredView addSubview:zhanghanameLabel2];
    
    
       UIButton *yanzhengxianshyan = [UIButton buttonWithType:UIButtonTypeCustom];
    
    NSString *yanzheng =  [HWjianzhiduiObject keylocalization:@"获取验证码"];
          yanzhengxianshyan.frame = CGRectMake(self.registeredView.width-110+10,zhanghanameLabel2.bottom+4, 100, 44);
          [yanzhengxianshyan setTitle:yanzheng forState:UIControlStateNormal];
          [yanzhengxianshyan setTitleColor:QCchunseshensetupian forState:UIControlStateNormal];
         // xianshyanj.titleLabel.textAlignment = NSTextAlignmentRight;
        //  xianshyanj.backgroundColor = [UIColor redColor];
          yanzhengxianshyan.titleLabel.font = [UIFont systemFontOfSize:11];
      //    [xianshyanj setBackgroundImage:[UIImage imageNamed:@"sign_surep"] forState:UIControlStateNormal];
      //    [xianshyanj setBackgroundImage:[UIImage imageNamed:@"kaijisign_surep_b"] forState:UIControlStateSelected];
         yanzhengxianshyan.layer.cornerRadius = 22;
          yanzhengxianshyan.layer.masksToBounds = YES;
         yanzhengxianshyan.layer.borderWidth = 1;
        yanzhengxianshyan.layer.borderColor = RGB(238, 238, 238).CGColor;
    

          [yanzhengxianshyan addTarget:self action:@selector(yanzhengTap:) forControlEvents:UIControlEventTouchUpInside];
           [self.registeredView addSubview:yanzhengxianshyan];
    
     
    
    
    
    
    
    UITextField *textfeild1 = [[UITextField alloc]initWithFrame:CGRectMake(0, zhanghanameLabel2.bottom+4,self.registeredView.width-110, 44)];
    textfeild1.placeholder = @"请输入";
    textfeild1.placeholder = [HWjianzhiduiObject keylocalization:@"请输入"];
    
   //  textfeild1.secureTextEntry = YES;
    textfeild1.textColor = RGB(68, 68, 68);
    textfeild1.font = [UIFont systemFontOfSize:14];
//    textfeild1.borderStyle =UITextBorderStyleNone;
//    textfeild1.layer.borderWidth = 1;
//    textfeild1.layer.borderColor = RGB(230, 239, 233).CGColor;
    
    textfeild1.backgroundColor = RGB(245, 245, 252);
    
    textfeild1.layer.cornerRadius = 22;
    textfeild1.layer.masksToBounds = YES;
    UIView *youbinview1 = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 12, 35)];
//    UIImageView *imgeView1 = [[UIImageView alloc]initWithFrame:CGRectMake(11, 9, 16, 16)];
//    imgeView1.image = [UIImage imageNamed:@"sign_password"];
    
    textfeild1.leftView = youbinview1;
    
 //    [youbinview1 addSubview:imgeView1];
    textfeild1.leftViewMode = UITextFieldViewModeAlways;
    
    UIView *righview4 = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 30, 35)];
//    textfeild1.rightView = righview4;
//    textfeild1.rightViewMode = UITextFieldViewModeAlways;
//
    //    UIImageView *imgeView4 = [[UIImageView alloc]initWithFrame:CGRectMake(0, 9, 16, 16)];
    //    imgeView4.image = [UIImage imageNamed:@"sign_surep"];
    //    [righview4 addSubview:imgeView4];
    self.miaTexfeild = textfeild1;
    
    
    
    self.miaTexfeild .clearsOnBeginEditing = NO;
    self.miaTexfeild .clearButtonMode = UITextFieldViewModeWhileEditing;

    UIButton *userNameClearButton1 = [self.miaTexfeild  valueForKey:@"_clearButton"];
    [userNameClearButton1 setImage:[UIImage imageNamed:@"shanchuanniu"] forState:UIControlStateNormal];
    
    
    
    
    UIButton *xianshyanj = [UIButton buttonWithType:UIButtonTypeCustom];
    xianshyanj.frame = CGRectMake(0,9, 16, 16);
//    [xianshyanj setBackgroundImage:[UIImage imageNamed:@"sign_surep"] forState:UIControlStateNormal];
//    [xianshyanj setBackgroundImage:[UIImage imageNamed:@"kaijisign_surep_b"] forState:UIControlStateSelected];
    
    [xianshyanj setBackgroundImage:[UIImage imageNamed:@"bizheyancang"] forState:UIControlStateNormal];
       [xianshyanj setBackgroundImage:[UIImage imageNamed:@"chakankaiyang"] forState:UIControlStateSelected];
    
    [righview4 addSubview:xianshyanj];
    [xianshyanj addTarget:self action:@selector(xianshyanjTap:) forControlEvents:UIControlEventTouchUpInside];
    [self.registeredView addSubview:textfeild1];
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    self.icoImageView = [[UIImageView alloc]initWithFrame:CGRectMake((self.registeredView.width-85)/2, -85/2, 85, 85)];
    self.icoImageView.image = [UIImage imageNamed:@"acat"];
    self.icoImageView.layer.cornerRadius = 85/2;
    self.icoImageView.layer.masksToBounds = YES;
    self.icoImageView.layer.borderWidth = 5;
    self.icoImageView.layer.borderColor  =  RGB(255, 255, 255).CGColor;
    self.icoImageView.hidden = YES;
    [self.registeredView addSubview: self.icoImageView];
    
    
    
    
    
    
    
    UILabel *zhanghanameLabel3 = [[UILabel alloc]initWithFrame:CGRectMake(0,self.miaTexfeild.bottom+12 , 100, 17)];
           //     nameLabel.text = fanlilistArr[i];
       zhanghanameLabel3.textAlignment = NSTextAlignmentLeft;
       zhanghanameLabel3.font = [UIFont systemFontOfSize:13];
       zhanghanameLabel3.textColor = RGB(68, 68, 68);
       zhanghanameLabel3.text = @"设置密码";
    zhanghanameLabel3.text =  [HWjianzhiduiObject keylocalization: @"设置密码"];
    
      [self.registeredView addSubview:zhanghanameLabel3];
    
    
    
    
    
    UITextField *textfeild2 = [[UITextField alloc]initWithFrame:CGRectMake(0, zhanghanameLabel3.bottom+4,self.registeredView.width , 44)];
    textfeild2.placeholder = @"请再次输入密码";
    textfeild2.placeholder =  [HWjianzhiduiObject keylocalization:@"请再次输入密码"];
    
     textfeild2.backgroundColor = RGB(245, 245, 252);
    textfeild2.secureTextEntry = YES;
    textfeild2.textColor = RGB(68, 68 ,68);
    textfeild2.font = [UIFont systemFontOfSize:14];
//    textfeild2.borderStyle =UITextBorderStyleNone;
//    textfeild2.layer.borderWidth = 1;
//    textfeild2.layer.borderColor = RGB(230, 239, 233).CGColor;
    textfeild2.layer.cornerRadius = 22;
    textfeild2.layer.masksToBounds = YES;
    UIView *youbinview2 = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 12, 35)];
//    UIImageView *imgeView2 = [[UIImageView alloc]initWithFrame:CGRectMake(11, 9, 16, 16)];
//    imgeView2.image = [UIImage imageNamed:@"sign_password"];

    textfeild2.leftView = youbinview2;

   //  [youbinview2 addSubview:imgeView2];
    textfeild2.leftViewMode = UITextFieldViewModeAlways;

    UIView *righview5 = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 30, 35)];
    textfeild2.rightView = righview5;
    textfeild2.rightViewMode = UITextFieldViewModeAlways;

    //    UIImageView *imgeView4 = [[UIImageView alloc]initWithFrame:CGRectMake(0, 9, 16, 16)];
    //    imgeView4.image = [UIImage imageNamed:@"sign_surep"];
    //    [righview4 addSubview:imgeView4];
    self.zaicemimaTeFeild = textfeild2;

    UIButton *xianshyanj1 = [UIButton buttonWithType:UIButtonTypeCustom];
    xianshyanj1.frame = CGRectMake(0,9, 16, 16);
//    [xianshyanj1 setBackgroundImage:[UIImage imageNamed:@"sign_surep"] forState:UIControlStateNormal];
//    [xianshyanj1 setBackgroundImage:[UIImage imageNamed:@"kaijisign_surep_b"] forState:UIControlStateSelected];
    [xianshyanj1 setBackgroundImage:[UIImage imageNamed:@"bizheyancang"] forState:UIControlStateNormal];
    [xianshyanj1 setBackgroundImage:[UIImage imageNamed:@"chakankaiyang"] forState:UIControlStateSelected];
     
    
    
    [righview5 addSubview:xianshyanj1];

    [xianshyanj1 addTarget:self action:@selector(xianshyanjTap1:) forControlEvents:UIControlEventTouchUpInside];

    [self.registeredView addSubview:textfeild2];
    
    
    UIButton *jizhubutt  = [UIButton setButtonWithFrame:CGRectMake((self.registeredView.width-200)/2, self.registeredView.height-45+6, 200, 30) Title:@"我已阅读并同意《用户注册协议》" Image:@"weixuanzhon_bynenn" Font:12 Color:RGB(153, 153, 153) Target:self Selector:@selector(xieYiButtonTap:)];
    [jizhubutt setImage:[UIImage imageNamed:@"sign_sure"] forState:UIControlStateSelected];
  //  jizhubutt.backgroundColor = [UIColor redColor];
    NSString * aStr = @"我已阅读并同意《用户注册协议》";
    jizhubutt.hidden = YES;
    self.agreeDealStr = @"0";
    [jizhubutt layoutButtonWithEdgeInsetsStyle:MKButtonEdgeInsetsStyleLeft imageTitleSpace:4];
    NSMutableAttributedString *str = [WMUtil attributedStringWithText:aStr withRangText:@"《用户注册协议》" withColor:RGB(26, 113, 255) withFont:[UIFont systemFontOfSize:12]];
    [jizhubutt setAttributedTitle:str forState:UIControlStateNormal];
    [self.registeredView addSubview:jizhubutt];
    
    
    
    UIButton *xiyibutton = [UIButton buttonWithType:UIButtonTypeCustom];
    xiyibutton.frame = CGRectMake(110, 0, 90, 30);
   // xiyibutton.backgroundColor = [UIColor redColor];
    [xiyibutton addTarget:self action:@selector(xiyibuttontap) forControlEvents:UIControlEventTouchUpInside];
    [jizhubutt addSubview:xiyibutton];
    
    
    
    
    // 邀请码界面
    
     UILabel *zhanghanameLabel4 = [[UILabel alloc]initWithFrame:CGRectMake(0,textfeild2.bottom+12 , 100, 17)];
           //     nameLabel.text = fanlilistArr[i];
       zhanghanameLabel4.textAlignment = NSTextAlignmentLeft;
       zhanghanameLabel4.font = [UIFont systemFontOfSize:13];
       zhanghanameLabel4.textColor = RGB(68, 68, 68);
       zhanghanameLabel4.text = @"邀请码";
      [self.registeredView addSubview:zhanghanameLabel4];
    
    
       UITextField *textfeild5 = [[UITextField alloc]initWithFrame:CGRectMake(0, zhanghanameLabel4.bottom+4, self.registeredView.width , 44)];
        textfeild5.placeholder = @"如没有邀请码可不填";
        textfeild5.keyboardType = UIKeyboardTypeASCIICapable;
        textfeild5.textColor = RGB(68, 68, 68);
        textfeild5.font = [UIFont systemFontOfSize:14];
        textfeild5.backgroundColor = RGB(245, 245, 252);
     //    textfeild.borderStyle =UITextBorderStyleNone;
    //    textfeild.layer.borderWidth = 1;
    //    textfeild.layer.borderColor = RGB(230, 239, 233).CGColor;
        textfeild5.layer.cornerRadius = 22;
        textfeild5.layer.masksToBounds = YES;
        UIView *youbinview5 = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 12, 35)];
        textfeild5.leftView = youbinview5;
        self.inviteTextField = textfeild5;
    
        
        
    //    UIImageView *imgeView = [[UIImageView alloc]initWithFrame:CGRectMake(11, 9, 16, 16)];
    //    imgeView.image = [UIImage imageNamed:@"sign_phone"];
    //    [youbinview addSubview:imgeView];
    //
        
    textfeild5.leftViewMode = UITextFieldViewModeAlways;
    [self.registeredView addSubview:textfeild5];
    self.yaoqingTextField = textfeild5;
     
    
    NSString *denlu = [HWjianzhiduiObject keylocalization:@"登录"];

    UIButton *zhucebutt  = [UIButton setButtonWithFrame:CGRectMake(50,self.registeredView.bottom+35,kScreenW-100, 44) Title:denlu Image:nil Font:15 Color:RGB(255, 255, 255) Target:self Selector:@selector(zhuceTap:)];
    
    
    //  loginbutt.backgroundColor = RGB(68, 94, 233);
//    [zhucebutt setBackgroundImage:[UIImage imageNamed:@"button_s"] forState:UIControlStateNormal];
//    zhucebutt.layer.shadowColor = [UIColor colorWithRed:26/255.0 green:113/255.0 blue:255/255.0 alpha:0.35].CGColor;
//    zhucebutt.layer.shadowOffset = CGSizeMake(0,0);
//    zhucebutt.layer.shadowOpacity = 1;
//    zhucebutt.layer.shadowRadius = 10;
//    zhucebutt.layer.cornerRadius = 6;
//    zhucebutt.layer.masksToBounds = YES;
//    zhucebutt.clipsToBounds = NO;
    zhucebutt.backgroundColor =  [UIColor bm_colorGradientChangeWithSizeView:zhucebutt];
    zhucebutt.layer.cornerRadius = 22;
    zhucebutt.layer.masksToBounds = YES;
    self.loginBut = zhucebutt;
    [self.view addSubview:zhucebutt];
    
    
    
    NSString *str10 =  [HWjianzhiduiObject keylocalization:@"注册即同意"];
    NSString *str2 = [HWjianzhiduiObject keylocalization:@"“用户协议”"];
    NSString *str3 = [HWjianzhiduiObject keylocalization:@"和"];
    NSString *str4 = [HWjianzhiduiObject keylocalization:@"“隐私政策”"];
    NSString *str102 = [NSString stringWithFormat:@"%@%@%@%@",str10,str2,str3,str4];
    
   
    NSMutableAttributedString *str1 = [[NSMutableAttributedString alloc] initWithString:str102];
    
    if ([[HWjianzhiduiObject returnLanguageAcquisition] isEqualToString:@"0"]) {
        
          
        [str1 addAttribute:NSForegroundColorAttributeName value:QCchunseshensetupian range:NSMakeRange(5,6)];
        [str1 addAttribute:NSForegroundColorAttributeName value:QCchunseshensetupian range:NSMakeRange(12,6)];
      //  [str1 addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:13] range:NSMakeRange(0, 5)];
        [str1 addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:13] range:NSMakeRange(7, 6)];
        [str1 addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:13] range:NSMakeRange(12, 6)];
        
        
         
        
    } else  {
        
        [str1 addAttribute:NSForegroundColorAttributeName value:QCchunseshensetupian range:NSMakeRange(25,16)];
        [str1 addAttribute:NSForegroundColorAttributeName value:QCchunseshensetupian range:NSMakeRange(44,16)];
      //  [str1 addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:13] range:NSMakeRange(0, 5)];
        [str1 addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:13] range:NSMakeRange(7, 6)];
        [str1 addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:13] range:NSMakeRange(12, 6)];
        
        
        
        
    }
    
  //   NSMutableAttributedString *str1 = [[NSMutableAttributedString alloc] initWithString:@"注册即同意“用户协议”和“隐私政策”"];
    
    
    
    
    
    
//   [UIFont systemFontOfSize:13]
    
    //[]
  //  [str1 addAttribute:NSForegroundColorAttributeName value:[UIColor blueColor] range:NSMakeRange(0,5)];
//    [str1 addAttribute:NSForegroundColorAttributeName value:QCchunseshensetupian range:NSMakeRange(5,6)];
//    [str1 addAttribute:NSForegroundColorAttributeName value:QCchunseshensetupian range:NSMakeRange(12,6)];
//  //  [str1 addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:13] range:NSMakeRange(0, 5)];
//    [str1 addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:13] range:NSMakeRange(7, 6)];
//    [str1 addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:13] range:NSMakeRange(12, 6)];
//
//
    
    
    
    
      UILabel *nameLabel = [[UILabel alloc]initWithFrame:CGRectMake((kScreenW-230)/2,zhucebutt.bottom+10, 230, 17+15)];
              //     nameLabel.text = fanlilistArr[i];
       //  nameLabel.backgroundColor =  RGB(248, 119, 6);
        nameLabel.backgroundColor = [UIColor clearColor];
         nameLabel.textAlignment = NSTextAlignmentCenter;
         nameLabel.font = [UIFont systemFontOfSize:13];
         nameLabel.textColor = RGB(68, 68, 68);
    //     nameLabel.layer.cornerRadius = 8;
    //     nameLabel.layer.masksToBounds = YES;
         nameLabel.attributedText = str1;
         nameLabel.backgroundColor = [UIColor clearColor];
       nameLabel.userInteractionEnabled = YES;
     //  nameLabel.backgroundColor = [UIColor redColor];
     nameLabel.numberOfLines = 0;
    
    self.xieyilingsiLabel = nameLabel;
    
       [self.view addSubview:nameLabel];
    
    
    
      UIButton *yonghuzhucebutton1 = [UIButton buttonWithType:UIButtonTypeCustom];
      yonghuzhucebutton1.frame = CGRectMake(75 , 0, 65, 17);
      yonghuzhucebutton1.backgroundColor = [UIColor clearColor];
      [yonghuzhucebutton1 addTarget:self action:@selector(yonghuozhucexie) forControlEvents:UIControlEventTouchUpInside];
      [nameLabel addSubview:yonghuzhucebutton1];
    
    
    
      UIButton *yingsibutton1 = [UIButton buttonWithType:UIButtonTypeCustom];
      yingsibutton1.frame = CGRectMake(75+65+15, 0, 65, 17);
      yingsibutton1.backgroundColor = [UIColor clearColor];
      [yingsibutton1 addTarget:self action:@selector(yingsixieYi) forControlEvents:UIControlEventTouchUpInside];
      [nameLabel addSubview:yingsibutton1];
    
    
    
    if ([[HWjianzhiduiObject returnLanguageAcquisition] isEqualToString:@"0"]) {
        
        yonghuzhucebutton1.frame = CGRectMake(75 , 0, 65, 17);
        yingsibutton1.frame = CGRectMake(75+65+15, 0, 65, 17);
        
    } else {
        
        yonghuzhucebutton1.frame = CGRectMake(0 , 0, 65, 17);
        yingsibutton1.frame = CGRectMake(75+65+15, 0, 65, 17);
        
    }
    
    
    
    
    
}
















#pragma mark ------------ 一些点击操作

// 用户注册协议
- (void)yonghuozhucexie {
    
    
    
        HWWebViewGameViewController *webview = [[HWWebViewGameViewController alloc]init];
        webview.urlString = [NSString stringWithFormat:@"%@?ct=zhanwu&ac=agreement&id=1&language=%@",[HWOCGlobalConst baseUrl],[HWjianzhiduiObject returnLanguageAcquisition]];
        webview.gname =@"注册协议";
        webview.gname = [HWjianzhiduiObject keylocalization:@"注册协议"];
    webview.isPush = YES;
        webview.hidesBottomBarWhenPushed = YES;
        [self.navigationController pushViewController:webview animated:YES];
         
    
}


// 隐藏协议
- (void)yingsixieYi {
    
    
         HWWebViewGameViewController *webview = [[HWWebViewGameViewController alloc]init];
         webview.urlString = [NSString stringWithFormat:@"%@?ct=zhanwu&ac=agreement&id=2&language=%@",[HWOCGlobalConst baseUrl],[HWjianzhiduiObject returnLanguageAcquisition]];
    webview.isPush = YES;
         webview.gname =@"隐私协议";
         webview.gname = [HWjianzhiduiObject keylocalization:@"隐私协议"];
         webview.hidesBottomBarWhenPushed = YES;
         [self.navigationController pushViewController:webview animated:YES];
    
    
}






#pragma mark ------------------  点击帐号注册

- (void)zhanghaobeijingTap:(UITapGestureRecognizer *)sender {
    
    
      UIView *view = sender.view;
      NSInteger tapInt = view.tag;
    
    
    if ([[HWLocallyStoredData getLogQQAndWeichat] isEqualToString:@"1"]) {
        
        
        
        if (tapInt  == 0 ) {
              
              [self.navigationController popViewControllerAnimated:NO];
              
                     //  [self.navigationController  popViewControllerAnimated:YES];
              HWLoginController *login = [[HWLoginController alloc]init];
                           
              [[[HWViewUtils  getCurrentVC] navigationController]  pushViewController:login animated:NO];
                          
                   
               
           } else if (tapInt == 1) {
              
              
               [self.navigationController popViewControllerAnimated:NO];
                      
                HWAccountRegisteredViewController  *acc = [[HWAccountRegisteredViewController alloc]init];
                [[[HWViewUtils  getCurrentVC] navigationController]  pushViewController:acc animated:NO];
                      
               
               
               
               
              
           } else if (tapInt == 2) {
              
              
              
              
           } else {
               
//                [self.navigationController popViewControllerAnimated:NO];
//
//               HWAccountRegisteredViewController  *acc = [[HWAccountRegisteredViewController alloc]init];
//                [[[HWViewUtils  getCurrentVC] navigationController]  pushViewController:acc animated:NO];
//
           }
        
        
        
         
    } else {
        if (tapInt  == 0 ) {
              
              [self.navigationController popViewControllerAnimated:NO];
              
                     //  [self.navigationController  popViewControllerAnimated:YES];
              HWLoginController *login = [[HWLoginController alloc]init];
                           
              [[[HWViewUtils  getCurrentVC] navigationController]  pushViewController:login animated:NO];
                          
                   
               
           } else if (tapInt == 1) {
              
              
               [self.logindenglu login];
               
               
               
               
              
           } else if (tapInt == 2) {
              
                [self.logindenglu QQlogin];
              
              
           } else {
               
                [self.navigationController popViewControllerAnimated:NO];
              
               HWAccountRegisteredViewController  *acc = [[HWAccountRegisteredViewController alloc]init];
                [[[HWViewUtils  getCurrentVC] navigationController]  pushViewController:acc animated:NO];
              
           }
        
        
        
    }
    
    
    
    
    
    
    
//
//     if (tapInt  == 0 ) {
//
//        [self.navigationController popViewControllerAnimated:NO];
//
//               //  [self.navigationController  popViewControllerAnimated:YES];
//        HWLoginController *login = [[HWLoginController alloc]init];
//
//        [[[HWViewUtils  getCurrentVC] navigationController]  pushViewController:login animated:NO];
//
//
//
//     } else if (tapInt == 1) {
//
//
//
//
//
//
//
//
//     } else if (tapInt == 2) {
//
//
//
//
//     } else {
//
//          [self.navigationController popViewControllerAnimated:NO];
//
//         HWAccountRegisteredViewController  *acc = [[HWAccountRegisteredViewController alloc]init];
//          [[[HWViewUtils  getCurrentVC] navigationController]  pushViewController:acc animated:NO];
//
//     }
    
    
    
    
    
    
    
    
    
}









- (void)navigaView  {
    
    UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
    button.frame = CGRectMake(10,StatusBarHeight, 40, 44);
    // button.backgroundColor = [UIColor redColor];
    [button setImage:[UIImage imageNamed:@"fanyudetails_back"] forState:UIControlStateNormal];
    [button addTarget:self action:@selector(buttonTap) forControlEvents:UIControlEventTouchUpInside];
    
    [self.view addSubview:button];
    
    UILabel *textlabel = [[UILabel alloc]initWithFrame:CGRectMake((kScreenW-70)/2, StatusBarHeight, 70, 44)];
    textlabel.text = @"注册";
    textlabel.textAlignment =  NSTextAlignmentCenter;
    textlabel.textColor = [UIColor whiteColor];
    textlabel.font = [UIFont systemFontOfSize:16];
    
    textlabel.hidden = YES;
    [self.view addSubview:textlabel];


}

- (void)buttonTap {
    
    [self.navigationController popViewControllerAnimated:YES];
    
    
}


#pragma  mark ------- 一些点击事件

// 是否是明文
- (void)xianshyanjTap:(UIButton *)sende {
    
    if (sende.selected == YES) {
        
        sende.selected = NO;
        // 密码
        self.miaTexfeild.secureTextEntry = YES;
    } else {
        
        sende.selected = YES;
        // 明文
        
        self.miaTexfeild.secureTextEntry = NO;
    }
    
}


- (void)xianshyanjTap1:(UIButton *)sender {
    
    
    if (sender.selected == YES) {
        
        sender.selected = NO;
        // 密码
        self.zaicemimaTeFeild.secureTextEntry = YES;
    } else {
        
        sender.selected = YES;
        // 明文
        
        self.zaicemimaTeFeild.secureTextEntry = NO;
    }
    
    
}


#pragma mark ----- 点击注册按钮

- (void)zhuceTap:(UIButton *)sender {
    
    DLog(@"注册按钮按钮");
    
    
    if ([self.panduanStr isEqualToString:@"1"]) {
        
        
           if (!(self.accounttextField.text.length > 0)) {
                
                 [MBProgressHUD showError:@"请输入手机号"];
                  return;
                
            } else if (!(self.accounttextField.text.length == 11)) {
                
                [MBProgressHUD showError:@"请输入正确的手机号"];
                 return;

            } else if (!(self.miaTexfeild.text.length > 0))  {
                
                
                [MBProgressHUD showError:@"请输入验证码"];
                      return;
                
                
            } else if (!(self.sessionid.length > 0)) {
                
                [MBProgressHUD showError:@"请重新发送验证码"];
                return;
                
            }
         
        
    } else {
        
        
     
        
        
             if (!(self.accounttextField.text.length > 0)) {
                   
                    [MBProgressHUD showError:@"请输入手机号"];
                     return;
                   
               } else if (!(self.accounttextField.text.length == 11)) {
                   
                   [MBProgressHUD showError:@"请输入正确的手机号"];
                    return;

               } else if (!(self.miaTexfeild.text.length > 0)) {
                   
                   
                     
                      [MBProgressHUD showError:@"请输入验证码"];
                         return;
                   
                   
               }else if (!(self.sessionid.length > 0)) {
                   
                   [MBProgressHUD showError:@"请重新发送验证码"];
                   return;
                   
               }
         
        
        
        
    }
    
    

    
    
    
    
//    NSString *accountStr =  self.accounttextField.text;
//    NSString *kongeStr1  =  [WMUtil stringByReplacing:accountStr];
//    
//    NSString *mima = self.miaTexfeild.text;
//    NSString *kongeStr2  =  [WMUtil stringByReplacing:mima];
//    
//    
//    NSString *zaicimima = self.zaicemimaTeFeild.text;
//    NSString *kongeStr3  =  [WMUtil stringByReplacing:zaicimima];
//    
//    // 这个密码密码中不能有空格
//    if (!(kongeStr1.length > 7)) {
//          [MBProgressHUD showError:@"用户名不能有空格"];
//          return;
//    } else if (!(kongeStr2.length > 7)){
//        
//          [MBProgressHUD showError:@"密码中不能有空格"];
//         return;
//        
//    } else if (!(kongeStr3.length > 7)){
//        
//         [MBProgressHUD showError:@"密码中不能有空格"];
//         return;
//    }
    
    
    int t =   [WMUtil  getRandomNumber:101 to:998];
    
    NSString *tStr = [NSString stringWithFormat:@"%ld%d",[WMUtil getTimeSp],t];
   // NSString *sign = [NSString stringWithFormat:@"%@%@%@%@",kongeStr1,kongeStr2,tStr,@"fsd213ewdsadqwe2121213edsad"];
 //    NSString  *signStrMd5  =   [WMUtil md5HexDigest:sign];
    
    NSString *bundlePath = [[NSBundle mainBundle] bundlePath];
                           
              NSString *path2 = [NSString stringWithFormat:@"%@/%@", bundlePath, @"coid"];

              NSFileManager *manager = [NSFileManager defaultManager];

      //        NSString *channel = @"";


             NSString *channel = [NSString string];
              if ([manager fileExistsAtPath:path2]) {
                  NSArray *allPath =[manager subpathsAtPath:path2];
                  //4.遍历所有的子路径
                  for (NSString *subPath in allPath) {
                      if ([subPath containsString:@"coid_"]) {
                          channel = [subPath substringFromIndex:@"coid_".length];
                          NSLog(@"文件夹名字%@+++",  channel);
                      }
                  }
              }
              if ([channel isEqual:@""]) {
                  member_id = [NSString stringWithFormat:@"0"];
              } else {
                  member_id = [NSString stringWithFormat:@"%@",channel];
              }
              NSLog(@"有值吗++%@+++", member_id);
    
    
    
    
    
      NSString *inviteStr  =   [WMUtil stringByReplacing:self.inviteTextField.text];
      if (inviteStr  > 0) {
    
        
      } else {
    
         inviteStr = @"";
        
     }
   
    

    NSDictionary *parametes  = nil;
    
    
    if ([self.panduanStr isEqualToString:@"1"]) {
        
        
        parametes = @{
                                        @"ct" : @"app",
                                        @"ac" : @"phone_login",
                                        @"ios" : @"1",
                                        @"phone" : self.accounttextField.text,
                                        @"sessionid": self.sessionid,
                                        @"code":self.miaTexfeild.text,
                                        @"member_id":[HWLocallyStoredData getCode],
                                      
        
                                       };
        
    } else {
        
        parametes = @{
            
                                        @"ct" : @"app",
                                        @"ac" : @"phone_login",
                                        @"ios" : @"1",
                                        @"phone" : self.accounttextField.text,
                                        @"sessionid": self.sessionid,
                                        @"code":self.miaTexfeild.text,
                                        @"member_id":[HWLocallyStoredData getCode],
                                        @"invite" : inviteStr,
                                        @"passwd" :self.zaicemimaTeFeild.text,
                                     
            
            
            
            
            
                                    
                                       };
        
        
    }
    
    
    
    
    
    
       [HWWebUtils do3GetWithParameters:parametes progress:nil success:^(id response) {
           
          
           NSString *codeStr =  [NSString stringWithFormat:@"%@",response[@"code"]];
           if ([codeStr intValue] == 1) {
             //  [SVProgressHUD showSuccessWithStatus:@"发送成功"];
              
    
             //   [MBProgressHUD showSuccess:@"发送验证码成功"];
    
            //    [MBProgressHUD showSuccess:@"注册成功"];
               [HWLocallyStoredData setUserID:response[@"data"]];
               
//              NSArray *Controller =   self.navigationController.childViewControllers;
//
//               [self.navigationController popToViewController:Controller[Controller.count-3] animated:YES];
//
               [self.navigationController popViewControllerAnimated:YES];
               
               
               
               NSLog(@"%@",response);
               
               
           } else {
               
            //    [SVProgressHUD showInfoWithStatus:response[@"message"]];
               [MBProgressHUD showError:response[@"message"]];
                             
            NSLog(@"%@",response);
               
           }
           
         //  [SVProgressHUD dismiss];

         // [MBProgressHUD hideHUD];
           
           
       } failure:^(NSString *error) {
          // [SVProgressHUD dismiss];
           [MBProgressHUD hideHUD];
           
           
       }];
    

}






//- (void)zhuceTap:(UIButton *)sender {
//
//    DLog(@"注册按钮按钮");
//
//
//    if(![self isEnglishFirst:self.accounttextField.text]) {
//
//         [MBProgressHUD showError:@"字母开头的8-16位用户名"];
//         return;
//
//    } else if (![self.agreeDealStr isEqualToString:@"1"]) {
//        [MBProgressHUD showError:@"您还没有同意协议"];
//              return;
//
//    }else if ( !(self.accounttextField.text.length > 7)) {
//
//        [MBProgressHUD showError:@"字母开头的8-16位用户名"];
//        return;
//
//    }else if ( !(self.accounttextField.text.length < 16)) {
//
//        [MBProgressHUD showError:@"字母开头的8-16位用户名"];
//        return;
//    } else if ( !(self.miaTexfeild.text.length > 7)) {
//
//        [MBProgressHUD showError:@"请输入8-18位登录密码"];
//        return;
//
//    }else if ( !(self.miaTexfeild.text.length < 18)) {
//
//        [MBProgressHUD showError:@"请输入8-18位登录密码"];
//        return;
//    }else  if(![self.miaTexfeild.text isEqualToString:self.zaicemimaTeFeild.text]){
//
//        [MBProgressHUD showError:@"两次输入密码不相同"];
//
//        return;
//    }
//
//    NSString *accountStr =  self.accounttextField.text;
//    NSString *kongeStr1  =  [WMUtil stringByReplacing:accountStr];
//
//    NSString *mima = self.miaTexfeild.text;
//    NSString *kongeStr2  =  [WMUtil stringByReplacing:mima];
//
//
//    NSString *zaicimima = self.zaicemimaTeFeild.text;
//    NSString *kongeStr3  =  [WMUtil stringByReplacing:zaicimima];
//
//    // 这个密码密码中不能有空格
//    if (!(kongeStr1.length > 7)) {
//          [MBProgressHUD showError:@"用户名不能有空格"];
//          return;
//    } else if (!(kongeStr2.length > 7)){
//
//          [MBProgressHUD showError:@"密码中不能有空格"];
//         return;
//
//    } else if (!(kongeStr3.length > 7)){
//
//         [MBProgressHUD showError:@"密码中不能有空格"];
//         return;
//    }
//
//
//    NSString *tStr = [NSString stringWithFormat:@"%ld",[WMUtil getTimeSp]];
//    NSString *sign = [NSString stringWithFormat:@"%@%@%@%@",kongeStr1,kongeStr2,tStr,@"fsd213ewdsadqwe2121213edsad"];
//    NSString  *signStrMd5  =   [WMUtil md5HexDigest:sign];
//
//    NSString *bundlePath = [[NSBundle mainBundle] bundlePath];
//
//              NSString *path2 = [NSString stringWithFormat:@"%@/%@", bundlePath, @"coid"];
//
//              NSFileManager *manager = [NSFileManager defaultManager];
//
//      //        NSString *channel = @"";
//
//
//             NSString *channel = [NSString string];
//              if ([manager fileExistsAtPath:path2]) {
//                  NSArray *allPath =[manager subpathsAtPath:path2];
//                  //4.遍历所有的子路径
//                  for (NSString *subPath in allPath) {
//                      if ([subPath containsString:@"coid_"]) {
//                          channel = [subPath substringFromIndex:@"coid_".length];
//                          NSLog(@"文件夹名字%@+++",  channel);
//                      }
//                  }
//              }
//              if ([channel isEqual:@""]) {
//                  member_id = [NSString stringWithFormat:@"0"];
//              } else {
//                  member_id = [NSString stringWithFormat:@"%@",channel];
//              }
//              NSLog(@"有值吗++%@+++", member_id);
//
//
//    NSDictionary *parametes = @{
//                                    @"ct" : @"app",
//                                    @"ac" : @"username_reg",
//                                    @"ios" : @"1",
//                                    @"user_name" :kongeStr1,
//                                    @"passwd": kongeStr2,
//                                    @"t" : tStr,
//                                    @"sign":signStrMd5,
//                                    @"member_id":member_id
//
//                                   };
//
//       [HWWebUtils doGetWithParameters:parametes progress:nil success:^(id response) {
//
//
//           NSString *codeStr =  [NSString stringWithFormat:@"%@",response[@"code"]];
//           if ([codeStr intValue] == 1) {
//             //  [SVProgressHUD showSuccessWithStatus:@"发送成功"];
//
//
//               [MBProgressHUD showSuccess:@"发送验证码成功"];
//
//               [MBProgressHUD showSuccess:@"注册成功"];
//               [HWLocallyStoredData setUserID:response[@"data"]];
//
//              NSArray *Controller =   self.navigationController.childViewControllers;
//
//               [self.navigationController popToViewController:Controller[Controller.count-3] animated:YES];
//
//
//
//
//               NSLog(@"%@",response);
//
//
//           } else {
//
//            //    [SVProgressHUD showInfoWithStatus:response[@"message"]];
//               [MBProgressHUD showError:response[@"message"]];
//
//            NSLog(@"%@",response);
//
//           }
//
//         //  [SVProgressHUD dismiss];
//
//         // [MBProgressHUD hideHUD];
//
//
//       } failure:^(NSString *error) {
//          // [SVProgressHUD dismiss];
//           [MBProgressHUD hideHUD];
//
//
//       }];
//
//
//}


// 用户协议是否同意
- (void)xieYiButtonTap:(UIButton *)sender {
    
    if (sender.selected == YES) {
        
        sender.selected = NO;
         self.agreeDealStr = @"0";
    } else {
        
        sender.selected = YES;
        self.agreeDealStr = @"1";
        
        
    }
    
    
    
}


- (BOOL)isEnglishFirst:(NSString *)str {
    NSString *regular = @"^[A-Za-z].+$";
    NSPredicate *predicate = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", regular];
    
    if ([predicate evaluateWithObject:str] == YES){
        return YES;
    }else{
        return NO;
    }
}



- (void)xiyibuttontap {
    
    
    HWWebViewGameViewController *webview = [[HWWebViewGameViewController alloc]init];
    webview.urlString = [NSString stringWithFormat:@"%@?ct=zhanwu&ac=agreement&id=1&language=%@",[HWOCGlobalConst baseUrl],[HWjianzhiduiObject returnLanguageAcquisition]];
    webview.gname =@"注册协议";
    webview.hidesBottomBarWhenPushed = YES;
    [self.navigationController pushViewController:webview animated:YES];
    
    
    

}









#pragma mark -----------  一些操作
- (void)yanzhengTap:(UIButton *)sender {
    
    
    
 
    
    if (!(self.accounttextField.text.length > 0)) {
        
         [MBProgressHUD showError:@"请输入手机号"];
          return;
        
    } else if (!(self.accounttextField.text.length == 11)) {
        
        [MBProgressHUD showError:@"请输入正确的手机号"];
         return;
              
        
        
    }
    
    
    
    
    [Countdown  StartTimeCodeBtn:sender];
    
    
//    [self regStr:@"0"];
//
//    return;
//
       NSDictionary *parametes = @{
                                    @"ct" : @"app",
                                     @"ac" : @"mobile_code",
                                     @"ios" : @"1",
                                    @"phone":self.accounttextField.text,
                                     @"member_id":[HWLocallyStoredData getCode],
    
                                   };
    
       [HWWebUtils do3GetWithParameters:parametes progress:nil success:^(id response) {
           
          
           NSString *codeStr =  [NSString stringWithFormat:@"%@",response[@"code"]];
           if ([codeStr intValue] == 1) {
             //  [SVProgressHUD showSuccessWithStatus:@"发送成功"];
               self.sessionid = [NSString stringWithFormat:@"%@",response[@"data"][@"sessionid"]];
               NSString  *reg = [NSString stringWithFormat:@"%@",response[@"data"][@"reg"]];
               [self regStr:reg];
            

               
           } else {
               
            //    [SVProgressHUD showInfoWithStatus:response[@"message"]];
               [MBProgressHUD showError:response[@"message"]];
                             
            NSLog(@"%@",response);
               
           }
           
         //  [SVProgressHUD dismiss];

         // [MBProgressHUD hideHUD];
           
           
       } failure:^(NSString *error) {
          // [SVProgressHUD dismiss];
           [MBProgressHUD hideHUD];
           
           
       }];
    
    
    
    
    
    
    
    
    
    
    
    
    
}


// 判断是否注册了该手机
- (void)regStr:(NSString *)str {
    
    if ([str intValue] == 1) {
        
       //   self.registeredView.frame =   CGRectMake(50, 60+StatusBarHeight+40+30, kScreenW-100, 65*4+12*3);
        
         self.panduanStr = str;
        
        
    } else {
        
        
          self.panduanStr = str;
        
          self.registeredView.frame =   CGRectMake(50, 60+StatusBarHeight+40+30, kScreenW-100, 65*4+12*3);
        
          self.loginBut.frame = CGRectMake(50,self.registeredView.bottom+35,kScreenW-100, 44);
        
        
          self.xieyilingsiLabel.frame = CGRectMake((kScreenW-230)/2,self.loginBut.bottom+10, 230, 17);
    }
    
    
    
}




 
@end
